<?php
namespace kernel\library;

class Single
{
    //单例属性
    protected static $ins = [];
    // 构造函数私有化
    final protected function __construct()
    {}
    
    // 防止克隆对象
    private function __clone()
    {}
    /**
     * 单例入口
     * @return static
     */
    static public function getInstance()
    {
        $class = get_called_class();
        if (isset(self::$ins[$class])) {
            return self::$ins[$class];
        }
        $self = new static();
        self::$ins[$class] = $self;
        return $self;
    }
}

